package com.yunxin.download.server.infra.utils;

import lombok.extern.slf4j.Slf4j;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @author zero°
 * @since 2023-06-15
 */
@Slf4j
public enum DateUtils {

    /**
     * 实例
     */
    X;

    public String getDateStr(Date date, String regx) {
        SimpleDateFormat format = new SimpleDateFormat(regx);
        return date == null ? format.format(new Date()) : format.format(date);
    }

    /**
     * 新增几天时间
     * @param date date
     * @param n n
     * @return Date
     */
    public Date addDay(Date date, int n) {
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        c.add(Calendar.DATE, n);
        return c.getTime();
    }
}

